/-editor
/-files
FileEntry.ts
FileList.ts
FolderEntry.ts
functions.ts
/-files-old
/-imports
/-layout
/-storage
/-tests ...
/-tests/files ...
FileList.ts
/-tests/storage
TestCase.ts
TestPage.ts
_sampleTests.ts
/-typings
TypeScriptService.ts
functions.ts
ko.ts
persistence.ts
shell.ts
teapo.html
teapo.js
teapo.ts
x
 
1
module teapo.tests.FileListTests {
2
3
  export function constructor_succeeds() { 
4
    var fl = new teapo.files.FileList();
5
  }
6
7
  export function constructor_null_succeeds() {
8
    var fl = new teapo.files.FileList(null);
9
  }
10
11
  export function constructor_empty_succeeds() {
12
    var fl = new teapo.files.FileList([]);
13
  }
14
15
  export function constructor_single_simple() {
16
    var fl = new teapo.files.FileList(['root.txt']);
17
    if (fl.folders().length) throw new Error('Should not have any folders, '+fl.folders().length);
18
    if (fl.files().length!==1) throw new Error('File expected, found ' + fl.files().length);
19
    if (fl.files()[0].name !== 'root.txt') throw new Error('Expected "root.txt", ' + fl.files()[0].name);
20
    if (fl.files()[0].path !== '/root.txt') throw new Error('Expected "/root.txt", ' + fl.files()[0].path);
21
  }
22
23
  export function constructor_single_root() {
24
    var fl = new teapo.files.FileList(['/root.txt']);
25
    if (fl.folders().length) throw new Error('Should not have any folders, ' + fl.folders().length);
26
    if (fl.files().length!==1) throw new Error('File expected, found ' + fl.files().length);
27
    if (fl.files()[0].name !== 'root.txt') throw new Error('Expected "root.txt", ' + fl.files()[0].name);
28
    if (fl.files()[0].path !== '/root.txt') throw new Error('Expected "/root.txt", ' + fl.files()[0].path);
29
  }
30
31
  export function constructor_single_rootAndTrailSlash() {
32
    var fl = new teapo.files.FileList(['/root.txt/']);
33
    if (fl.folders().length) throw new Error('Should not have any folders, ' + fl.folders().length);
34
    if (fl.files().length !== 1) throw new Error('File expected, found ' + fl.files().length);
35
    if (fl.files()[0].name !== 'root.txt') throw new Error('Expected "root.txt", ' + fl.files()[0].name);
36
    if (fl.files()[0].path !== '/root.txt') throw new Error('Expected "/root.txt", ' + fl.files()[0].path);
37
  }
38
    
39
  export function constructor_single_nest1() {
40
    var fl = new teapo.files.FileList(['/fold/root.txt']);
41
    if (fl.files().length) throw new Error('No root files expected, ' + fl.files().length);
42
    if (fl.folders().length!==1) throw new Error('Folder expected, found ' + fl.folders().length);
43
    var fold = fl.folders()[0];
44
    if (fold.name !== 'fold') throw new Error('Expected "fold", ' + fold.name);
45
    if (fold.path !== '/fold/') throw new Error('Expected "/fold/", ' + fold.path);
46
    if (fold.folders().length) throw new Error('Shoud not have subfolders, ' + fold.folders().length);
47
48
    if (fold.files().length !== 1) throw new Error('File expected, found ' + fold.files().length);
49
    if (fold.files()[0].name !== 'root.txt') throw new Error('Expected "root.txt", ' + fold.files()[0].name);
50
    if (fold.files()[0].path !== '/fold/root.txt') throw new Error('Expected "/fold/root.txt", ' + fold.files()[0].path);
51
  }
52
53
  export function file_simple() {
54
    var fl = new teapo.files.FileList();
55
    fl.file('root.txt');
56
    if (fl.folders().length) throw new Error('Should not have any folders, ' + fl.folders().length);
57
    if (fl.files().length !== 1) throw new Error('File expected, found ' + fl.files().length);
58
    if (fl.files()[0].name !== 'root.txt') throw new Error('Expected "root.txt", ' + fl.files()[0].name);
59
    if (fl.files()[0].path !== '/root.txt') throw new Error('Expected "/root.txt", ' + fl.files()[0].path);
60
  }
61
3:28 module typeof teapo.files